package com.lc.user.express.ordering;

import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.amap.api.services.core.LatLonPoint;
import com.amap.api.services.route.BusRouteResult;
import com.amap.api.services.route.DrivePath;
import com.amap.api.services.route.DriveRouteResult;
import com.amap.api.services.route.RideRouteResult;
import com.amap.api.services.route.RouteSearch;
import com.amap.api.services.route.WalkRouteResult;
import com.lc.user.express.BaseSecondActivity;
import com.lc.user.express.R;
import com.lc.user.express.adapter.AddrAdapter;
import com.lc.user.express.app.AppContext;
import com.lc.user.express.httpserver.GetAddrInfo;
import com.lc.user.express.httpserver.GetNeedDetails;
import com.lc.user.express.httpserver.GetPointMoney;
import com.lc.user.express.model.AddrModel;
import com.lc.user.express.my.LoginActivity;
import com.lc.user.express.utils.GetToast;
import com.lc.user.express.utils.Logger;
import com.lc.user.express.utils.PublicMethod;
import com.lc.user.express.view.DatePopup;
import com.lc.user.express.view.MyListView;
import com.lc.user.express.view.dialog.AffirmDialog;
import com.lc.user.express.view.dialog.InPutDialog;
import com.zcx.helper.http.AsyCallBack;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * Created by Administrator on 2016/3/3. 完善订单信息
 */
public class OrderInfoCompleteActivity extends BaseSecondActivity implements RouteSearch.OnRouteSearchListener {

    public static final int TYPE_REORDER = 0x11;
    public static OnAddrListChoosed onAddrListChoosed = null;//常用地址选择
    public static OnMessageToDiver onMessageToDiver = null;//捎句话
    public static OnAddrChange onAddrChange = null;//地址对外接口
    public static OnPointMoney onPointMoney = null;//预估价格

    private TextView tv_public;
    private String cityId = AppContext.myPreferences.getCityId();

    private TextView tv_add_end_addr;//添加目的地
    private ListView lv;//地址列表
    private List<AddrModel> list = new ArrayList<>();//地址列表数据
    private AddrAdapter adapter;//地址列表adapter

    private RelativeLayout rl_need_carry, rl_need_receipt, rl_rec_money;//需要搬运 需要回单 需要回款
    private TextView tv_need_carry, tv_need_receipt, tv_rec_money;//需要搬运 需要回单 需要回款
    private String tmoney = "";//回款

    private LinearLayout ll_message_to_diver;//给司机捎句话
    private TextView tv_message_to_diver;//给司机捎句话
    private String strMessage;//给司机捎句话临时存储

    private LinearLayout ll_time;//用车时间
    private TextView tv_time;//用车时间
    private String dataTime = "";//服务器需要的时间形式
    private int datetype = 1;//用车时间类型 1现在 2明天 3其他时间

    private TextView tv_details1, tv_details2, tv_details3;//回单回款详情
    private LinearLayout ll_details;//回单回款详情
    private LinearLayout ll_details_info;//回单回款详情
    private TextView tv_shou;//回单回款详情 收起展开文字
    private ImageView iv_shou;//回单回款详情 收起展开图片
    public int isMove = 0;//是否需要搬运
    public int isbackorder = 0;//是否需要回单
    public int isbackmoney = 0;//是否需要回款

    private int tposition = -1;//记录点选地址位置
    private String routeId = "";//记录选用的常用地址id

    private TextView tv_money;//估计价格
    private TextView tv_coupon;//可使用优惠券
    private String money;//预估价格
    private String couponid;//减免优惠券id
    private String couponMoney;//减免优惠券金额
    private TextView tv_shuoming;//说明

    private boolean isBalance = false;

    private DriveRouteResult mDriveRouteResult;
    private RouteSearch mRouteSearch;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_complete_order_info);
        setTitle("完善订单信息");
        setRightButtonText("常用路线", 150);
        initView();
    }

    private void initView() {
        tv_public = (TextView) findViewById(R.id.tv_public);
        tv_public.setOnClickListener(this);//下一步
        tv_add_end_addr = (TextView) findViewById(R.id.tv_add_end_addr);
        tv_add_end_addr.setOnClickListener(this);
        tv_need_carry = (TextView) findViewById(R.id.tv_need_carry);
        tv_need_receipt = (TextView) findViewById(R.id.tv_need_receipt);
        tv_rec_money = (TextView) findViewById(R.id.tv_rec_money);
        rl_need_carry = (RelativeLayout) findViewById(R.id.rl_need_carry);
        rl_need_receipt = (RelativeLayout) findViewById(R.id.rl_need_receipt);
        rl_rec_money = (RelativeLayout) findViewById(R.id.rl_rec_money);
        rl_need_carry.setOnClickListener(this);
        rl_need_receipt.setOnClickListener(this);
        rl_rec_money.setOnClickListener(this);

        tv_message_to_diver = (TextView) findViewById(R.id.tv_message_to_diver);
        ll_message_to_diver = (LinearLayout) findViewById(R.id.ll_message_to_diver);
        ll_message_to_diver.setOnClickListener(this);

        ll_time = (LinearLayout) findViewById(R.id.ll_time);
        ll_time.setOnClickListener(this);
        tv_time = (TextView) findViewById(R.id.tv_time);

        ((ImageView) findViewById(R.id.iv_shou)).setOnClickListener(this);
        tv_details1 = (TextView) findViewById(R.id.tv_details1);
        tv_details2 = (TextView) findViewById(R.id.tv_details2);
        tv_details3 = (TextView) findViewById(R.id.tv_details3);
        tv_shuoming = (TextView) findViewById(R.id.tv_shuoming);
        detailsViewGone();
        ll_details = (LinearLayout) findViewById(R.id.ll_details);
        ll_details_info = (LinearLayout) findViewById(R.id.ll_details_info);
        tv_shou = (TextView) findViewById(R.id.tv_shou);
        iv_shou = (ImageView) findViewById(R.id.iv_shou);
        getNeedDetails();

        tv_money = (TextView) findViewById(R.id.tv_money);
        tv_coupon = (TextView) findViewById(R.id.tv_coupon);
        setMoneyView("约￥");

        lv = (MyListView) findViewById(R.id.lv);
        adapter = new AddrAdapter(cnt, list, true);
        lv.setAdapter(adapter);
        initAddrData();

        lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {

                deleteAddr(position);

                return true;
            }
        });
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                tposition = position;
                Bundle bundle = new Bundle();
                bundle.putSerializable("addr", list.get(position));
                if (position == 0) {
                    show(SearchAddrActivity.class, SearchAddrActivity.TYPE_S, bundle);
                } else {
                    show(SearchAddrActivity.class, SearchAddrActivity.TYPE_E, bundle);
                }
            }
        });

        onMessageToDiver = new OnMessageToDiver() {
            @Override
            public void onMessage(String str) {
                tv_message_to_diver.setText(str);
                strMessage = str;
            }
        };
        onAddrChange = new OnAddrChange() {
            @Override
            public void onAddr(AddrModel model) {
                if (tposition != -1) {
                    list.get(tposition).setAddr(model.getAddr());
                    list.get(tposition).setDistrict(model.getDistrict());
                    list.get(tposition).setLat(model.getLat());
                    list.get(tposition).setLng(model.getLng());
                    list.get(tposition).setName(model.getName());
                    list.get(tposition).setMobile(model.getMobile());
                    list.get(tposition).setPoint(model.getPoint());
                    adapter.updateListView(list);

                    searchRoute();
                }

            }
        };
        onAddrListChoosed = new OnAddrListChoosed() {
            @Override
            public void onChoosed(String tRouteId) {
                getAddrData(tRouteId);
            }
        };
        onPointMoney = new OnPointMoney() {
            @Override
            public void onPoint() {
                searchRoute();
            }
        };
    }

    private void detailsViewGone() {
        tv_details1.setVisibility(View.GONE);
        tv_details2.setVisibility(View.GONE);
        tv_details3.setVisibility(View.GONE);
    }

    /**
     * @param str 预估价格view，多颜色
     */
    private void setMoneyView(String str) {
        tv_money.setText(str);
        SpannableStringBuilder builder = new SpannableStringBuilder(tv_money.getText().toString());
        ForegroundColorSpan redSpan = new ForegroundColorSpan(Color.parseColor("#e78737"));
        builder.setSpan(redSpan, 1, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        tv_money.setText(builder);

    }

    /**
     * 高德地图路径规划 获得所有路线总距离
     */
    private void searchRoute() {
        int size = list.size();
        if (size <= 0) {//list为空，不预估价格
            return;
        }
        for (AddrModel model : list) {//list有经纬度为空的，不预算价格
            if (TextUtils.isEmpty(model.getPoint())) {
                return;
            }
        }
        tv_money.setText("正在预估价格...");
        tv_coupon.setText(getResources().getString(R.string.fee_instructions));
        tv_public.setClickable(false);
        mRouteSearch = new RouteSearch(cnt);
        mRouteSearch.setRouteSearchListener(this);
        List<LatLonPoint> latLonPoints = new ArrayList<>();

        for (int i = 0; i < size; i++) {
            LatLonPoint point = new LatLonPoint(list.get(i).getLat(), list.get(i).getLng());
            latLonPoints.add(point);
        }
        LatLonPoint mStartPoint = new LatLonPoint(list.get(0).getLat(), list.get(0).getLng());//起点，
        LatLonPoint mEndPoint = new LatLonPoint(list.get(size - 1).getLat(), list.get(size - 1).getLng());//终点
        final RouteSearch.FromAndTo fromAndTo = new RouteSearch.FromAndTo(mStartPoint, mEndPoint);

        RouteSearch.DriveRouteQuery query = new RouteSearch.DriveRouteQuery(fromAndTo, RouteSearch.DrivingShortDistance, latLonPoints,
                null, "");// 第一个参数表示路径规划的起点和终点，第二个参数表示驾车模式，第三个参数表示途经点，第四个参数表示避让区域，第五个参数表示避让道路
        mRouteSearch.calculateDriveRouteAsyn(query);// 异步路径规划驾车模式查询
    }

    /**
     * @param result    高德地图路线规划算距离回调
     * @param errorCode
     */
    @Override
    public void onDriveRouteSearched(DriveRouteResult result, int errorCode) {
        if (errorCode == 1000) {
            if (result != null && result.getPaths() != null) {
                if (result.getPaths().size() > 0) {
                    mDriveRouteResult = result;
                    RouteSearch.DriveRouteQuery query = new RouteSearch.DriveRouteQuery(null, 2, null, null, "");
                    mDriveRouteResult.setDriveQuery(query);
                    final DrivePath drivePath = mDriveRouteResult.getPaths()
                            .get(0);

                    getPointMoney(drivePath.getDistance());

                } else if (result != null && result.getPaths() == null) {

                }

            } else {

            }
        } else {

        }
    }


    @Override
    public void onWalkRouteSearched(WalkRouteResult result, int errorCode) {
    }

    @Override
    public void onRideRouteSearched(RideRouteResult rideRouteResult, int i) {

    }

    @Override
    public void onBusRouteSearched(BusRouteResult result, int errorCode) {
    }

    @Override
    public void onClick(View v) {
        super.onClick(v);
        switch (v.getId()) {
            case R.id.head_right:
                if (AppContext.myPreferences.getIsLogin()) {
                   /* Bundle bundle = new Bundle();
                    //bundle.putString("routeid", routeId);
                    bundle.putString("routeid",routeId);
                    Log.d(AppContext.myPreferences.readRouteId(),"ddddddddddddddddd");


                    show(SelectUsedRouteActivity.class, bundle);*/

                    Intent intent=new Intent();


//                    intent.putExtra("routeid",routeId);
                    intent.putExtra("routeid",AppContext.myPreferences.readRouteId());


                    intent.setClass(OrderInfoCompleteActivity.this,SelectUsedRouteActivity.class);
                    startActivity(intent);



                } else {
                    show(LoginActivity.class, LoginActivity.TYPE_LOGIN);
                }

                break;
            case R.id.tv_add_end_addr://添加地址，添加一条空数据
                AddrModel model = new AddrModel();
                model.setAddr("");
                list.add(model);
                adapter.updateListView(list);
                break;
            case R.id.rl_need_carry:

                if (rl_need_carry.isSelected()) {
                    rl_need_carry.setSelected(false);
                    tv_need_carry.setSelected(false);
                    isMove = 0;
                    stateSelect();
                } else {
                    detailsViewGone();
                    rl_need_carry.setSelected(true);
                    tv_need_carry.setSelected(true);
                    isMove = 1;

                    stateSelect();
                }
                detailsView();
                break;
            case R.id.rl_need_receipt:


                if (rl_need_receipt.isSelected()) {
                    rl_need_receipt.setSelected(false);
                    tv_need_receipt.setSelected(false);
                    isbackorder = 0;
                    stateSelect();
                } else {
                    detailsViewGone();
                    rl_need_receipt.setSelected(true);
                    tv_need_receipt.setSelected(true);
                    isbackorder = 1;

                    stateSelect();
                }
                detailsView();
                break;
            case R.id.rl_rec_money:
                if (rl_rec_money.isSelected()) {
                    rl_rec_money.setSelected(false);
                    tv_rec_money.setSelected(false);
                    stateSelect();
                    detailsView();
                } else {
                    showInputDialog();
                    stateSelect();
                }
                break;
            case R.id.ll_message_to_diver:
                Bundle bundle = new Bundle();
                bundle.putString("message", strMessage);
                show(MessageToDiverActivity.class, bundle);
                break;
            case R.id.ll_time:
                showTimePopupWindow();
                break;
            case R.id.iv_shou:
                needDetails();
                break;
            case R.id.tv_public:
                for (AddrModel model1 : list) {
                    if (TextUtils.isEmpty(model1.getAddr())) {
                        GetToast.useString(cnt, "请完善地址信息");
                        return;
                    }
                }
                if (AppContext.myPreferences.getIsLogin()) {

                    Bundle bundle1 = new Bundle();
                    bundle1.putString("cid", getIntent().getStringExtra("cid"));
                    bundle1.putSerializable("addrs", (Serializable) list);
                    bundle1.putString("datetime", dataTime);
                    bundle1.putInt("datetype", datetype);
                    bundle1.putString("money", money);
                    bundle1.putInt("ismove", isMove);
                    bundle1.putInt("isbackorder", isbackorder);
                    bundle1.putInt("isbackmoney", isbackmoney);
                    bundle1.putString("backmoney", tmoney);
                    bundle1.putString("couponid", couponid);
                    bundle1.putString("saycontent", tv_message_to_diver.getText().toString().trim());
                    bundle1.putString("time", tv_time.getText().toString().toString());
                    bundle1.putString("car_name", getIntent().getStringExtra("car_name"));
                    bundle1.putString("coupom_money", couponMoney);
                    show(OrderInfoSureActivity.class, bundle1);
                } else {
                    show(LoginActivity.class, LoginActivity.TYPE_LOGIN);
                }
                break;
        }


    }

    private void stateSelect() {
        if (rl_need_carry.isSelected() && rl_need_carry.isSelected() && rl_rec_money.isSelected()) {
            detailsViewGone();
            tv_shuoming.setText("搬运,回单,回款详细说明");
            tv_details1.setVisibility(View.VISIBLE);
            tv_details2.setVisibility(View.VISIBLE);
            tv_details3.setVisibility(View.VISIBLE);
        } else if (rl_need_receipt.isSelected() && rl_need_carry.isSelected()) {
            detailsViewGone();
            tv_shuoming.setText("搬运,回单详细说明");
            tv_details1.setVisibility(View.VISIBLE);
            tv_details2.setVisibility(View.VISIBLE);

        } else if (rl_need_carry.isSelected() && rl_rec_money.isSelected()) {
            tv_shuoming.setText("搬运,汇款详细说明");
            detailsViewGone();
            tv_details1.setVisibility(View.VISIBLE);

            tv_details3.setVisibility(View.VISIBLE);
        } else if (rl_need_receipt.isSelected()) {
            detailsViewGone();
            tv_shuoming.setText("回单详细说明");
            tv_details2.setVisibility(View.VISIBLE);
        } else if (rl_need_carry.isSelected()) {
            detailsViewGone();
            tv_shuoming.setText("搬运详细说明");
            tv_details1.setVisibility(View.VISIBLE);
        } else if (rl_rec_money.isSelected()) {
            detailsViewGone();
            tv_shuoming.setText("回款详细说明");
            tv_details3.setVisibility(View.VISIBLE);
        }
    }

    /**
     * 构造两条地址空数据，用来显示
     */
    private void initTwoAddrData() {
        AddrModel model = new AddrModel();
        model.setAddr("");
        list.add(model);
        AddrModel model1 = new AddrModel();
        model.setAddr("");
        list.add(model1);
        adapter.updateListView(list);
    }

    /**
     * 初始化地址数据
     */
    private void initAddrData() {
        if (getIntent().getFlags() == TYPE_REORDER) {//再次下单
            list = (List<AddrModel>) getIntent().getSerializableExtra("addrs");
            if (list == null || list.size() <= 0) {
                initTwoAddrData();
            } else {
                adapter.updateListView(list);
                searchRoute();
            }
        } else {
            initTwoAddrData();
        }

    }

    /**
     * 选择时间
     */
    private void showTimePopupWindow() {
        DatePopup popupWindow = new DatePopup(cnt, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        popupWindow.showAtLocation((LinearLayout) findViewById(R.id.ll_parent), Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
        popupWindow.setOnClickOk(new DatePopup.OnClickOk() {
            @Override
            public void onClickOk(String date, String hour, String minute, int position) {
                if ("立即用车".equals(hour)) {
                    tv_time.setText("现在");
                    dataTime = "";
                    datetype = 1;
                } else {
                    tv_time.setText(date + " " + hour.substring(0, hour.length() - 1) + ":" + minute.substring(0, minute.length() - 1));
                    dataTime = getDateFormat(position) + " " + hour.substring(0, hour.length() - 1) + ":" + minute.substring(0, minute.length() - 1);
                    if ("明天".equals(date)) {
                        datetype = 2;
                    } else {
                        datetype = 3;
                    }
                }

                Logger.print("lll", "dataTime=" + dataTime);
            }
        });
    }

    private String getDateFormat(int position) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        Calendar c = Calendar.getInstance();
        int temp = c.get(Calendar.DAY_OF_MONTH) + position;
        c.set(Calendar.DAY_OF_MONTH, temp);
        return format.format(c.getTime());


    }

    /**
     * 详细需求
     */
    private void needDetails() {
        if (ll_details_info.getVisibility() == View.VISIBLE) {
            ll_details_info.setVisibility(View.GONE);
            tv_shou.setText("展开");
            iv_shou.setBackgroundResource(R.mipmap.zhan);
        } else {
            ll_details_info.setVisibility(View.VISIBLE);
            tv_shou.setText("收起");
            iv_shou.setBackgroundResource(R.mipmap.shou);
        }

    }

    /**
     * @param position 删除地址
     */
    private void deleteAddr(final int position) {
        if (position == 0 || list.size() <= 2) {
            return;
        }
        new AffirmDialog(cnt, "确定删除该目的地吗？", "取消", "确定", R.style.MyDialog) {

            @Override
            protected void onYesClick() {

                // TODO Auto-generated method stub
                list.remove(position);
                adapter.updateListView(list);
                searchRoute();

            }
        }.show();
    }

    /**
     * @param tRouteId 常用地址选择
     */
    private void getAddrData(final String tRouteId) {
        if (TextUtils.isEmpty(tRouteId) || "-99".equals(tRouteId)) {//不使用常用路线
            list.clear();
//            routeId = "";

            routeId = AppContext.myPreferences.readRouteId();
            initTwoAddrData();
            setMoneyView("约￥");
            tv_coupon.setText(getResources().getString(R.string.fee_instructions));
            couponid = "";
            money = "";
            couponMoney = "";
            return;
        }
        new GetAddrInfo(AppContext.myPreferences.getUid(), tRouteId, new AsyCallBack<GetAddrInfo.Info>() {
            @Override
            public void onSuccess(String toast, int type, GetAddrInfo.Info info) throws Exception {

                if (info.dataList != null && info.dataList.size() > 0) {
                    list.clear();
                    list.addAll(info.dataList);
                    adapter.updateListView(list);
                    routeId = tRouteId;
                    searchRoute();
                }

            }
        }).execute(cnt);
    }

    /**
     * 需带回款对话框
     */
    private void showInputDialog() {
        final InPutDialog dialog = new InPutDialog(cnt);
        dialog.setTitle("司机需带回");
        dialog.setInputKey("金额");
        dialog.setHint("最高10000元");
        dialog.setMaxValue(10000);
        dialog.setMaxLength(5);
        dialog.setText(tmoney);
        dialog.setNo("取消");
        dialog.setYes("确认");
        dialog.setDialogOnClickListener(new InPutDialog.DialogOnClickListener() {
            @Override
            public void Yes(String temp) {
                if (TextUtils.isEmpty(temp)) {
                    GetToast.useString(cnt, "请输入金额");
                } else if ("0".equals(temp)) {
                    GetToast.useString(cnt, "金额不能为0");
                } else if (!PublicMethod.formatDecimal(temp)) {
                    GetToast.useString(cnt, "数字格式错误");
                } else {
                    rl_rec_money.setSelected(true);
                    tv_rec_money.setSelected(true);
                    tmoney = temp;
                    dialog.cancel();
                    detailsView();
                    isbackmoney = 1;
                    stateSelect();
                }

            }
        });
        dialog.show();
    }

    /**
     * 计算预估价格
     */
    private void getPointMoney(float distance) {
//        Toast.makeText(this,""+distance,Toast.LENGTH_LONG).show();
        new GetPointMoney(AppContext.myPreferences.getUid(), AppContext.myPreferences.getCityId(), String.valueOf(distance), getIntent().getStringExtra("cid"), new AsyCallBack<GetPointMoney.Info>() {
            @Override
            public void onSuccess(String toast, int type, GetPointMoney.Info info) throws Exception {
                tv_public.setClickable(true);
                setMoneyView("约￥" + info.account);
                money = info.account;
                couponid = info.couponid;
                couponMoney = info.couponmoney;
                if ("0".equals(info.couponmoney)) {
                    tv_coupon.setText("暂无优惠券可用");
                } else {
                    String s = "优惠券已减免" + info.couponmoney + "元";
                    SpannableStringBuilder builder = new SpannableStringBuilder(s);
                    ForegroundColorSpan redSpan = new ForegroundColorSpan(Color.parseColor("#e78737"));
                    builder.setSpan(redSpan, 6, s.length() - 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
                    tv_coupon.setText(builder);
                }

            }
        }).execute(cnt, false);
    }

    /**
     * 收起 展开
     */
    private void detailsView() {
        if (rl_need_receipt.isSelected() || rl_need_carry.isSelected() || rl_rec_money.isSelected()) {
            ll_details.setVisibility(View.VISIBLE);
        } else {
            ll_details.setVisibility(View.GONE);
        }
    }

    private void getNeedDetails() {
        new GetNeedDetails(new AsyCallBack<GetNeedDetails.Info>() {
            @Override
            public void onSuccess(String toast, int type, GetNeedDetails.Info info) throws Exception {
                tv_details1.setText("司机独立搬运：\n" + info.web_myselftmove);//搬运
                tv_details2.setText("司机协助搬运：\n" + info.web_drivermove);//回单
                tv_details3.setText("回单、回款：\n" + info.web_backinfo);//回款
            }
        }).execute(cnt);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        onMessageToDiver = null;
        onAddrChange = null;
        onAddrListChoosed = null;
        onPointMoney = null;

    }

    /**
     * 监听给司机捎句话内容
     */
    public interface OnMessageToDiver {
        void onMessage(String str);
    }

    /**
     * 监听地址选择
     */
    public interface OnAddrChange {
        void onAddr(AddrModel model);
    }

    public interface OnAddrListChoosed {
        void onChoosed(String tRouteId);
    }

    public interface OnPointMoney {
        void onPoint();
    }

}
